package com.lanju.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lanju.dao.LogsDao;
import com.lanju.entity.PageLogs;
import com.lanju.service.LogsService;
@Service
public class LogsServiceImpl implements LogsService{

	@Autowired
	LogsDao logsDao;
	
	
	@Override
	@Transactional(value="financialmarketingTM", rollbackFor = Exception.class)
	public Map<String, Object> insertLogs(Map<String, Object> map) {
		Map<String, Object> result=new HashMap<String, Object>();
		try {
			PageLogs logs=new PageLogs();
			logs.setCreateTime(new Date());
			logs.setDomain(map.get("domain").toString());
			logs.setUrl(map.get("url").toString());
			logs.setLogId(UUID.randomUUID().toString());
			logs.setIp(map.get("ip").toString());
			logsDao.insertLogs(logs);
			result.put("success", true);
		} catch (Exception e) {
			e.printStackTrace();
			result.put("success", false);
		}
		return result;
	}

}
